﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class linkedit : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["UserID"]==null)
		{
			Response.Write("<script>alert('你没有管理员权限，禁止访问！');history.back();</script>");
		}
		if (!Page.IsPostBack)
        {
            string id = Request.QueryString["id"];
            HiddenID.Value = id;
            if (!string.IsNullOrEmpty(id))
            {
                DataSet ds = Socut.Data.ExecuteDataSet("select linkname,linkurl,linkorder from web_link where id=" + id);
                STRtitle.Text = ds.Tables[0].Rows[0][0].ToString();
				STRsite.Text = ds.Tables[0].Rows[0][1].ToString();
                STRorder.Text = ds.Tables[0].Rows[0][2].ToString();
            }
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        string Msg, Url;
        if (string.IsNullOrEmpty(HiddenID.Value))
        {
            Socut.Data.ExecuteNonQuery("insert into web_link (linkname,linkurl,linkorder) values ('" + STRtitle.Text + "','" +  STRsite.Text + "','" +  STRorder.Text + "')");
            Msg = "添加成功！";
            Url = "linkmanage.aspx";
        }
        else
        {
            Socut.Data.ExecuteNonQuery("update web_link set linkname='" + STRtitle.Text + "',linkurl='" +  STRsite.Text + "',linkorder='" +  STRorder.Text + "' where id=" + HiddenID.Value);
            Msg = "修改成功！";
            Url = "linkmanage.aspx";
        }
        CommonFunction.ShowMessage(Msg,Url);
    }
}
